package cn.bqjr.eily.samples.common.shiro;

import cn.bqjr.eily.samples.entity.po.UrlFilter;
import cn.bqjr.eily.samples.service.base.IUrlFilterService;
import cn.bqjr.eily.shiro.spring.boot.IShiroUrlFilterService;
import cn.bqjr.eily.shiro.spring.boot.entity.ShiroUrlFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ShiroUrlFilterService implements IShiroUrlFilterService{

    @Autowired
    private IUrlFilterService urlFilterService;

    @Override
    public List<ShiroUrlFilter> selectAll() {
        List<UrlFilter> filters = urlFilterService.selectAll();
        List<ShiroUrlFilter> shiroUrlFilters = new ArrayList<>(filters.size());
        filters.forEach(filter -> shiroUrlFilters.add(
                new ShiroUrlFilter().setFilterUrl(filter.getFilterUrl()).setFilterList(filter.getFilterList())));
        return shiroUrlFilters;
    }
}
